package com.codeplateform.service.impl;

import com.codeplateform.dao.RegisterDao;
import com.codeplateform.dao.entity.Register;
import com.codeplateform.dao.entity.RegisterExample;
import com.codeplateform.service.LoginService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LoginServiceImpl implements LoginService {

    @Autowired
    RegisterDao registerDao;

    @Override
    public Register select(Register register) {

        RegisterExample register1=new RegisterExample();
        register1.createCriteria().andUsernameEqualTo(register.getUsername())
                                  .andPasswordEqualTo(register.getPassword());

        Register registers = registerDao.selectByExample(register1).get(0);

        if (null!=registers){
            return registers;
        }
      return null;
    }
}
